package cn.home.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.service.domain.HomePerformanceTeam;
import cn.home.service.service.IHomePerformanceTeamService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 团队业绩目标Controller
 * 
 * @author xsc
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/teamper/teamper")
public class HomePerformanceTeamController extends BaseController
{
    @Autowired
    private IHomePerformanceTeamService homePerformanceTeamService;

    /**
     * 查询团队业绩目标列表
     */
    @PreAuthorize("@ss.hasPermi('teamper:teamper:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomePerformanceTeam homePerformanceTeam)
    {
        startPage();
        List<HomePerformanceTeam> list = homePerformanceTeamService.selectHomePerformanceTeamList(homePerformanceTeam);
        return getDataTable(list);
    }

    /**
     * 导出团队业绩目标列表
     */
    @PreAuthorize("@ss.hasPermi('teamper:teamper:export')")
    @Log(title = "团队业绩目标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomePerformanceTeam homePerformanceTeam)
    {
        List<HomePerformanceTeam> list = homePerformanceTeamService.selectHomePerformanceTeamList(homePerformanceTeam);
        ExcelUtil<HomePerformanceTeam> util = new ExcelUtil<HomePerformanceTeam>(HomePerformanceTeam.class);
        util.exportExcel(response, list, "团队业绩目标数据");
    }

    /**
     * 获取团队业绩目标详细信息
     */
    @PreAuthorize("@ss.hasPermi('teamper:teamper:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(homePerformanceTeamService.selectHomePerformanceTeamById(id));
    }

    /**
     * 新增团队业绩目标
     */
    @PreAuthorize("@ss.hasPermi('teamper:teamper:add')")
    @Log(title = "团队业绩目标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomePerformanceTeam homePerformanceTeam)
    {
        return toAjax(homePerformanceTeamService.insertHomePerformanceTeam(homePerformanceTeam));
    }

    /**
     * 修改团队业绩目标
     */
    @PreAuthorize("@ss.hasPermi('teamper:teamper:edit')")
    @Log(title = "团队业绩目标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomePerformanceTeam homePerformanceTeam)
    {
        return toAjax(homePerformanceTeamService.updateHomePerformanceTeam(homePerformanceTeam));
    }

    /**
     * 删除团队业绩目标
     */
    @PreAuthorize("@ss.hasPermi('teamper:teamper:remove')")
    @Log(title = "团队业绩目标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(homePerformanceTeamService.deleteHomePerformanceTeamByIds(ids));
    }
}
